home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / EVENT.H < prev    next >
C/C++ Source or Header  |  1991-11-30  |  3KB  |  105 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Input events.
  25.  */
  26.  
  27. #ifndef event_h
  28. #define event_h
  29.  
  30. #include <InterViews/defs.h>
  31.  
  32. enum EventType {
  33.     MotionEvent,    /* mouse moved */
  34.     DownEvent,        /* button pressed */
  35.     UpEvent,        /* button released */
  36.     KeyEvent,        /* key pressed, intepreted as ascii */
  37.     EnterEvent,        /* mouse enters canvas */
  38.     LeaveEvent,        /* mouse leaves canvas */
  39.     ChannelEvent,    /* input pending on channel */
  40.     TimerEvent,        /* time out on read */
  41.     FocusInEvent,    /* focus for keyboard events */
  42.     FocusOutEvent     /* lose keyboard focus */
  43. };
  44.  
  45. /* obsolete */
  46. static const int OnEvent = EnterEvent;
  47. static const int OffEvent = LeaveEvent;
  48.  
  49. /* mouse buttons */
  50. static const int LEFTMOUSE = 0;
  51. static const int MIDDLEMOUSE = 1;
  52. static const int RIGHTMOUSE = 2;
  53.  
  54. typedef boolean EventFlag;
  55.  
  56. class EventRep;
  57. class Interactor;
  58. class World;
  59.  
  60. class Event {
  61. public:
  62.     Interactor* target;
  63.     unsigned long timestamp;
  64.     EventType eventType;
  65.     Coord x, y;            /* mouse position relative to target */
  66.     EventFlag control : 1;    /* true if down */
  67.     EventFlag meta : 1;
  68.     EventFlag shift : 1;
  69.     EventFlag shiftlock : 1;
  70.     EventFlag leftmouse : 1;
  71.     EventFlag middlemouse : 1;
  72.     EventFlag rightmouse : 1;
  73.     unsigned char button;    /* button pressed or released, if any */
  74.     unsigned short len;        /* length of ASCII string */
  75.     char* keystring;        /* ASCII interpretation of event, if any */
  76.     int channel;        /* set of channels ready */
  77.  
  78.     Event();
  79.     ~Event();
  80.  
  81.     Event& operator=(Event&);
  82.     void GetAbsolute(Coord&, Coord&);
  83.     void GetAbsolute(World*&, Coord&, Coord&);
  84.     EventRep* Rep() { return rep; }
  85. private:
  86.     friend class Sensor;
  87.     friend class Interactor;
  88.  
  89.     World* w;            /* world in which event occurred */
  90.     Coord wx, wy;        /* mouse position relative to world */
  91.     char keydata[sizeof(int)];    /* keystring points here for simple mappings */
  92.     EventRep* rep;
  93.  
  94.     void GetMotionInfo();
  95.     void GetButtonInfo(EventType);
  96.     void GetKeyInfo();
  97.     void GetKeyState(unsigned);
  98.     void GetKeybState();
  99.     boolean GetCrossingInfo(EventType);
  100.     void FindWorld(void*);
  101.     void GetRootCoord(int, int);
  102. };
  103.  
  104. #endif
  105.